module game(
	input CLOCK_50,
	input key1 ,
	input key2 ,
	input key3 ,
	input iCLK1,iCLK2,
	input [9:0] px,
	input [9:0] py,
	input [10:0] SW,
	output reg valid,
	output pixel,
	output reg red,
	output reg green,
	output reg blue,
	output [6:0]	HEX0,HEX1,HEX2,HEX3
);
		//random gap wires
		wire [9:0]deck0;
		wire [9:0]deck1;
		wire [9:0]deck2;
		wire [9:0]deck3;
		wire [9:0]deck4;
		wire [9:0]deck5;
		wire [9:0]deck6;
		wire [9:0]deck7;
		wire [9:0]deck8;
		wire [9:0]deck9;
		wire [9:0]deck10;
		wire [9:0]deck11;
		wire [9:0]deck12;
		wire [9:0]deck13;
		wire [9:0]deck14;
		wire [9:0]deck15;
		wire [9:0]deck16;
		wire [9:0]deck17;
		wire [9:0]deck18;
		wire [9:0]deck19;
		wire [9:0]deck20;
		wire [9:0]deck21;
		wire [9:0]deck22;
		wire [9:0]deck23;
		wire [9:0]deck24;
		wire [9:0]deck25;
		wire [9:0]deck26;
		wire [9:0]deck27;
		wire [9:0]deck28;
		wire [9:0]deck29;
		wire [9:0]deck30;
		wire [9:0]deck31;

//left feedback shift registers for each platform
lfsr rand0(CLOCK_50,key3,10'd200,deck0);
lfsr rand1(CLOCK_50,key3,10'd13,deck1);
lfsr rand2(CLOCK_50,key3,10'd110,deck2);
lfsr rand3(CLOCK_50,key3,10'd500,deck3);
lfsr rand4(CLOCK_50,key3,10'd30,deck4);
lfsr rand5(CLOCK_50,key3,10'd300,deck5);
lfsr rand6(CLOCK_50,key3,10'd310,deck6);
lfsr rand7(CLOCK_50,key3,10'd220,deck7);
lfsr rand8(CLOCK_50,key3,10'd16,deck8);
lfsr rand9(CLOCK_50,key3,10'd1,deck9);
lfsr rand10(CLOCK_50,key3,10'd150,deck10);
lfsr rand11(CLOCK_50,key3,10'd95,deck11);
lfsr rand12(CLOCK_50,key3,10'd4,deck12);
lfsr rand13(CLOCK_50,key3,10'd31,deck13);
lfsr rand14(CLOCK_50,key3,10'd99,deck14);
lfsr rand15(CLOCK_50,key3,10'd460,deck15);
lfsr rand16(CLOCK_50,key3,10'd420,deck16);
lfsr rand17(CLOCK_50,key3,10'd437,deck17);
lfsr rand18(CLOCK_50,key3,10'd239,deck18);
lfsr rand19(CLOCK_50,key3,10'd141,deck19);
lfsr rand20(CLOCK_50,key3,10'd543,deck20);
lfsr rand21(CLOCK_50,key3,10'd145,deck21);
lfsr rand22(CLOCK_50,key3,10'd46,deck22);
lfsr rand23(CLOCK_50,key3,10'd48,deck23);
lfsr rand24(CLOCK_50,key3,10'd249,deck24);
lfsr rand25(CLOCK_50,key3,10'd350,deck25);
lfsr rand26(CLOCK_50,key3,10'd252,deck26);
lfsr rand27(CLOCK_50,key3,10'd263,deck27);
lfsr rand28(CLOCK_50,key3,10'd255,deck28);
lfsr rand29(CLOCK_50,key3,10'd154,deck29);
lfsr rand30(CLOCK_50,key3,10'd157,deck30);
lfsr rand31(CLOCK_50,key3,10'd160,deck31);

//timer set to 50 million
parameter TIMER = 50000000;

//counter register
reg [32:0]count;

//game over register
reg gameOver;

//player registers
reg [11:0]playerx[1:0];//[0]==left [1]==right
reg [11:0]playery[1:0];//[0]==top  [1]==bot

//platform registers
reg [11:0]platformA[5:0]; //[0]==left border [1]==begin gap [2]==end gap [3]right border [4]==top [5]==bot
reg [11:0]platformB[5:0];
reg [11:0]platformC[5:0];
reg [11:0]platformD[5:0];
reg [11:0]platformE[5:0];
reg [11:0]platformF[5:0];
reg [11:0]platformG[5:0];
reg [11:0]platformH[5:0];
reg [11:0]platformI[5:0];
reg [11:0]platformJ[5:0];
reg [11:0]platformK[5:0];
reg [11:0]platformL[5:0];
reg [11:0]platformM[5:0];
reg [11:0]platformN[5:0];
reg [11:0]platformO[5:0];
reg [11:0]platformP[5:0];
reg [11:0]platformQ[5:0];
reg [11:0]platformR[5:0];
reg [11:0]platformS[5:0];
reg [11:0]platformT[5:0];
reg [11:0]platformU[5:0];
reg [11:0]platformV[5:0];
reg [11:0]platformW[5:0];
reg [11:0]platformX[5:0];
reg [11:0]platformY[5:0];
reg [11:0]platformZ[5:0];
reg [11:0]platformAA[5:0];
reg [11:0]platformBB[5:0];
reg [11:0]platformCC[5:0];
reg [11:0]platformDD[5:0];
reg [11:0]platformEE[5:0];
reg [11:0]platformFF[5:0];

//screen collision registers
reg collisionx[1:0];//[0]==left [1]==right
reg collisiony[1:0];//[0]==top  [1]==bot

//playform collision registers
reg [1:0]collisionyA; //[0]==bot //needs to be wire if using collisionCheck module
reg [1:0]collisionxA; //[0]==left [1]==right
reg [1:0]collisionyB;
reg [1:0]collisionxB;
reg [1:0]collisionyC;
reg [1:0]collisionxC;
reg [1:0]collisionyD;
reg [1:0]collisionxD;
reg [1:0]collisionyE;
reg [1:0]collisionxE;
reg [1:0]collisionyF;
reg [1:0]collisionxF;
reg [1:0]collisionyG;
reg [1:0]collisionxG;
reg [1:0]collisionyH;
reg [1:0]collisionxH;
reg [1:0]collisionyI;
reg [1:0]collisionxI;
reg [1:0]collisionyJ;
reg [1:0]collisionxJ;
reg [1:0]collisionyK;
reg [1:0]collisionxK;
reg [1:0]collisionyL;
reg [1:0]collisionxL;
reg [1:0]collisionyM;
reg [1:0]collisionxM;
reg [1:0]collisionyN;
reg [1:0]collisionxN;
reg [1:0]collisionyO;
reg [1:0]collisionxO;
reg [1:0]collisionyP;
reg [1:0]collisionxP;
reg [1:0]collisionyQ;
reg [1:0]collisionxQ;
reg [1:0]collisionyR;
reg [1:0]collisionxR;
reg [1:0]collisionyS;
reg [1:0]collisionxS;
reg [1:0]collisionyT;
reg [1:0]collisionxT;
reg [1:0]collisionyU;
reg [1:0]collisionxU;
reg [1:0]collisionyV;
reg [1:0]collisionxV;
reg [1:0]collisionyW;
reg [1:0]collisionxW;
reg [1:0]collisionyX;
reg [1:0]collisionxX;
reg [1:0]collisionyY;
reg [1:0]collisionxY;
reg [1:0]collisionyZ;
reg [1:0]collisionxZ;
reg [1:0]collisionyAA;
reg [1:0]collisionxAA;
reg [1:0]collisionyBB;
reg [1:0]collisionxBB;
reg [1:0]collisionyCC;
reg [1:0]collisionxCC;
reg [1:0]collisionyDD;
reg [1:0]collisionxDD;
reg [1:0]collisionyEE;
reg [1:0]collisionxEE;
reg [1:0]collisionyFF;
reg [1:0]collisionxFF;

always @ (*)
begin
	
	//screen collision check x 
	collisionx[0]=(playerx[0]==0 || (playerx[0]-1) == 0 || (playerx[0]-2) == 0 ||(playerx[0]-3) == 0); //left border
	collisionx[1]=(playerx[1]==640 || (playerx[1]+1) == 640 || (playerx[1]+2) == 640 ||(playerx[1]+3) == 640);	//right border

	//screen collision check y
	collisiony[0]=(playery[0]==0 || (playery[0]-1)==0); //ceiling
	collisiony[1]=(playery[1]==480 || (playery[1]-1)==480); //floor

	//platform collision check
	//floor
	collisionyA[0]=(((playery[1]==platformA[4] || (playery[1]+1)==platformA[4] || (playery[1]+2)==platformA[4]))&&(((playerx[1]>=platformA[0])&&(playerx[0]<=platformA[1]))||((playerx[1]>=platformA[2])&&(playerx[0]<=platformA[3]))))?1:0;
	collisionyB[0]=(((playery[1]==platformB[4] || (playery[1]+1)==platformB[4] || (playery[1]+2)==platformB[4]))&&(((playerx[1]>=platformB[0])&&(playerx[0]<=platformB[1]))||((playerx[1]>=platformB[2])&&(playerx[0]<=platformB[3]))))?1:0;
	collisionyC[0]=(((playery[1]==platformC[4] || (playery[1]+1)==platformC[4] || (playery[1]+2)==platformC[4]))&&(((playerx[1]>=platformC[0])&&(playerx[0]<=platformC[1]))||((playerx[1]>=platformC[2])&&(playerx[0]<=platformC[3]))))?1:0;
	collisionyD[0]=(((playery[1]==platformD[4] || (playery[1]+1)==platformD[4] || (playery[1]+2)==platformD[4]))&&(((playerx[1]>=platformD[0])&&(playerx[0]<=platformD[1]))||((playerx[1]>=platformD[2])&&(playerx[0]<=platformD[3]))))?1:0;
	collisionyE[0]=(((playery[1]==platformE[4] || (playery[1]+1)==platformE[4] || (playery[1]+2)==platformE[4]))&&(((playerx[1]>=platformE[0])&&(playerx[0]<=platformE[1]))||((playerx[1]>=platformE[2])&&(playerx[0]<=platformE[3]))))?1:0;
	collisionyF[0]=(((playery[1]==platformF[4] || (playery[1]+1)==platformF[4] || (playery[1]+2)==platformF[4]))&&(((playerx[1]>=platformF[0])&&(playerx[0]<=platformF[1]))||((playerx[1]>=platformF[2])&&(playerx[0]<=platformF[3]))))?1:0;
	collisionyG[0]=(((playery[1]==platformG[4] || (playery[1]+1)==platformG[4] || (playery[1]+2)==platformG[4]))&&(((playerx[1]>=platformG[0])&&(playerx[0]<=platformG[1]))||((playerx[1]>=platformG[2])&&(playerx[0]<=platformG[3]))))?1:0;
	collisionyH[0]=(((playery[1]==platformH[4] || (playery[1]+1)==platformH[4] || (playery[1]+2)==platformH[4]))&&(((playerx[1]>=platformH[0])&&(playerx[0]<=platformH[1]))||((playerx[1]>=platformH[2])&&(playerx[0]<=platformH[3]))))?1:0;
	collisionyI[0]=(((playery[1]==platformI[4] || (playery[1]+1)==platformI[4] || (playery[1]+2)==platformI[4]))&&(((playerx[1]>=platformI[0])&&(playerx[0]<=platformI[1]))||((playerx[1]>=platformI[2])&&(playerx[0]<=platformI[3]))))?1:0;
	collisionyJ[0]=(((playery[1]==platformJ[4] || (playery[1]+1)==platformJ[4] || (playery[1]+2)==platformJ[4]))&&(((playerx[1]>=platformJ[0])&&(playerx[0]<=platformJ[1]))||((playerx[1]>=platformJ[2])&&(playerx[0]<=platformJ[3]))))?1:0;
	collisionyK[0]=(((playery[1]==platformK[4] || (playery[1]+1)==platformK[4] || (playery[1]+2)==platformK[4]))&&(((playerx[1]>=platformK[0])&&(playerx[0]<=platformK[1]))||((playerx[1]>=platformK[2])&&(playerx[0]<=platformK[3]))))?1:0;
	collisionyL[0]=(((playery[1]==platformL[4] || (playery[1]+1)==platformL[4] || (playery[1]+2)==platformL[4]))&&(((playerx[1]>=platformL[0])&&(playerx[0]<=platformL[1]))||((playerx[1]>=platformL[2])&&(playerx[0]<=platformL[3]))))?1:0;
	collisionyM[0]=(((playery[1]==platformM[4] || (playery[1]+1)==platformM[4] || (playery[1]+2)==platformM[4]))&&(((playerx[1]>=platformM[0])&&(playerx[0]<=platformM[1]))||((playerx[1]>=platformM[2])&&(playerx[0]<=platformM[3]))))?1:0;
	collisionyN[0]=(((playery[1]==platformN[4] || (playery[1]+1)==platformN[4] || (playery[1]+2)==platformN[4]))&&(((playerx[1]>=platformN[0])&&(playerx[0]<=platformN[1]))||((playerx[1]>=platformN[2])&&(playerx[0]<=platformN[3]))))?1:0;
	collisionyO[0]=(((playery[1]==platformO[4] || (playery[1]+1)==platformO[4] || (playery[1]+2)==platformO[4]))&&(((playerx[1]>=platformO[0])&&(playerx[0]<=platformO[1]))||((playerx[1]>=platformO[2])&&(playerx[0]<=platformO[3]))))?1:0;
	collisionyP[0]=(((playery[1]==platformP[4] || (playery[1]+1)==platformP[4] || (playery[1]+2)==platformP[4]))&&(((playerx[1]>=platformP[0])&&(playerx[0]<=platformP[1]))||((playerx[1]>=platformP[2])&&(playerx[0]<=platformP[3]))))?1:0;
	collisionyQ[0]=(((playery[1]==platformQ[4] || (playery[1]+1)==platformQ[4] || (playery[1]+2)==platformQ[4]))&&(((playerx[1]>=platformQ[0])&&(playerx[0]<=platformQ[1]))||((playerx[1]>=platformQ[2])&&(playerx[0]<=platformQ[3]))))?1:0;
	collisionyR[0]=(((playery[1]==platformR[4] || (playery[1]+1)==platformR[4] || (playery[1]+2)==platformR[4]))&&(((playerx[1]>=platformR[0])&&(playerx[0]<=platformR[1]))||((playerx[1]>=platformR[2])&&(playerx[0]<=platformR[3]))))?1:0;
	collisionyS[0]=(((playery[1]==platformS[4] || (playery[1]+1)==platformS[4] || (playery[1]+2)==platformS[4]))&&(((playerx[1]>=platformS[0])&&(playerx[0]<=platformS[1]))||((playerx[1]>=platformS[2])&&(playerx[0]<=platformS[3]))))?1:0;
	collisionyT[0]=(((playery[1]==platformT[4] || (playery[1]+1)==platformT[4] || (playery[1]+2)==platformT[4]))&&(((playerx[1]>=platformT[0])&&(playerx[0]<=platformT[1]))||((playerx[1]>=platformD[2])&&(playerx[0]<=platformT[3]))))?1:0;
	collisionyU[0]=(((playery[1]==platformU[4] || (playery[1]+1)==platformU[4] || (playery[1]+2)==platformU[4]))&&(((playerx[1]>=platformU[0])&&(playerx[0]<=platformU[1]))||((playerx[1]>=platformU[2])&&(playerx[0]<=platformU[3]))))?1:0;
	collisionyV[0]=(((playery[1]==platformV[4] || (playery[1]+1)==platformV[4] || (playery[1]+2)==platformV[4]))&&(((playerx[1]>=platformV[0])&&(playerx[0]<=platformV[1]))||((playerx[1]>=platformV[2])&&(playerx[0]<=platformV[3]))))?1:0;
	collisionyW[0]=(((playery[1]==platformW[4] || (playery[1]+1)==platformW[4] || (playery[1]+2)==platformW[4]))&&(((playerx[1]>=platformW[0])&&(playerx[0]<=platformW[1]))||((playerx[1]>=platformW[2])&&(playerx[0]<=platformW[3]))))?1:0;
	collisionyX[0]=(((playery[1]==platformX[4] || (playery[1]+1)==platformX[4] || (playery[1]+2)==platformX[4]))&&(((playerx[1]>=platformX[0])&&(playerx[0]<=platformX[1]))||((playerx[1]>=platformX[2])&&(playerx[0]<=platformX[3]))))?1:0;
	collisionyY[0]=(((playery[1]==platformY[4] || (playery[1]+1)==platformY[4] || (playery[1]+2)==platformY[4]))&&(((playerx[1]>=platformY[0])&&(playerx[0]<=platformY[1]))||((playerx[1]>=platformY[2])&&(playerx[0]<=platformY[3]))))?1:0;
	collisionyZ[0]=(((playery[1]==platformZ[4] || (playery[1]+1)==platformZ[4] || (playery[1]+2)==platformZ[4]))&&(((playerx[1]>=platformZ[0])&&(playerx[0]<=platformZ[1]))||((playerx[1]>=platformZ[2])&&(playerx[0]<=platformZ[3]))))?1:0;
	collisionyAA[0]=(((playery[1]==platformAA[4] || (playery[1]+1)==platformAA[4] || (playery[1]+2)==platformAA[4]))&&(((playerx[1]>=platformAA[0])&&(playerx[0]<=platformAA[1]))||((playerx[1]>=platformAA[2])&&(playerx[0]<=platformAA[3]))))?1:0;
	collisionyBB[0]=(((playery[1]==platformBB[4] || (playery[1]+1)==platformBB[4] || (playery[1]+2)==platformBB[4]))&&(((playerx[1]>=platformBB[0])&&(playerx[0]<=platformBB[1]))||((playerx[1]>=platformBB[2])&&(playerx[0]<=platformBB[3]))))?1:0;
	collisionyCC[0]=(((playery[1]==platformCC[4] || (playery[1]+1)==platformCC[4] || (playery[1]+2)==platformCC[4]))&&(((playerx[1]>=platformCC[0])&&(playerx[0]<=platformCC[1]))||((playerx[1]>=platformCC[2])&&(playerx[0]<=platformCC[3]))))?1:0;
	collisionyDD[0]=(((playery[1]==platformDD[4] || (playery[1]+1)==platformDD[4] || (playery[1]+2)==platformDD[4]))&&(((playerx[1]>=platformDD[0])&&(playerx[0]<=platformDD[1]))||((playerx[1]>=platformDD[2])&&(playerx[0]<=platformDD[3]))))?1:0;
	collisionyEE[0]=(((playery[1]==platformEE[4] || (playery[1]+1)==platformEE[4] || (playery[1]+2)==platformEE[4]))&&(((playerx[1]>=platformEE[0])&&(playerx[0]<=platformEE[1]))||((playerx[1]>=platformEE[2])&&(playerx[0]<=platformEE[3]))))?1:0;
	collisionyFF[0]=(((playery[1]==platformFF[4] || (playery[1]+1)==platformFF[4] || (playery[1]+2)==platformFF[4]))&&(((playerx[1]>=platformFF[0])&&(playerx[0]<=platformFF[1]))||((playerx[1]>=platformFF[2])&&(playerx[0]<=platformFF[3]))))?1:0;
	
	//left
	collisionxA[0]=((((playerx[0]-2)<=platformA[1]))&&((playery[0]<(platformA[5]))&&(playery[1]>platformA[4])))?1:0;	
	collisionxB[0]=((((playerx[0]-2)<=platformB[1]))&&((playery[0]<(platformB[5]))&&(playery[1]>platformB[4])))?1:0;
	collisionxC[0]=((((playerx[0]-2)<=platformC[1]))&&((playery[0]<(platformC[5]))&&(playery[1]>platformC[4])))?1:0;
	collisionxD[0]=((((playerx[0]-2)<=platformD[1]))&&((playery[0]<(platformD[5]))&&(playery[1]>platformD[4])))?1:0;
	collisionxE[0]=((((playerx[0]-2)<=platformE[1]))&&((playery[0]<(platformE[5]))&&(playery[1]>platformE[4])))?1:0;
	collisionxF[0]=((((playerx[0]-2)<=platformF[1]))&&((playery[0]<(platformF[5]))&&(playery[1]>platformF[4])))?1:0;
	collisionxG[0]=((((playerx[0]-2)<=platformG[1]))&&((playery[0]<(platformG[5]))&&(playery[1]>platformG[4])))?1:0;
	collisionxH[0]=((((playerx[0]-2)<=platformH[1]))&&((playery[0]<(platformH[5]))&&(playery[1]>platformH[4])))?1:0;
	collisionxI[0]=((((playerx[0]-2)<=platformI[1]))&&((playery[0]<(platformI[5]))&&(playery[1]>platformI[4])))?1:0;
	collisionxJ[0]=((((playerx[0]-2)<=platformJ[1]))&&((playery[0]<(platformJ[5]))&&(playery[1]>platformJ[4])))?1:0;
	collisionxK[0]=((((playerx[0]-2)<=platformK[1]))&&((playery[0]<(platformK[5]))&&(playery[1]>platformK[4])))?1:0;
	collisionxL[0]=((((playerx[0]-2)<=platformL[1]))&&((playery[0]<(platformL[5]))&&(playery[1]>platformL[4])))?1:0;
	collisionxM[0]=((((playerx[0]-2)<=platformM[1]))&&((playery[0]<(platformM[5]))&&(playery[1]>platformM[4])))?1:0;
	collisionxN[0]=((((playerx[0]-2)<=platformN[1]))&&((playery[0]<(platformN[5]))&&(playery[1]>platformN[4])))?1:0;
	collisionxO[0]=((((playerx[0]-2)<=platformO[1]))&&((playery[0]<(platformO[5]))&&(playery[1]>platformO[4])))?1:0;
	collisionxP[0]=((((playerx[0]-2)<=platformP[1]))&&((playery[0]<(platformP[5]))&&(playery[1]>platformP[4])))?1:0;
	collisionxQ[0]=((((playerx[0]-2)<=platformQ[1]))&&((playery[0]<(platformQ[5]))&&(playery[1]>platformQ[4])))?1:0;
	collisionxR[0]=((((playerx[0]-2)<=platformR[1]))&&((playery[0]<(platformR[5]))&&(playery[1]>platformR[4])))?1:0;
	collisionxS[0]=((((playerx[0]-2)<=platformS[1]))&&((playery[0]<(platformS[5]))&&(playery[1]>platformS[4])))?1:0;
	collisionxT[0]=((((playerx[0]-2)<=platformT[1]))&&((playery[0]<(platformT[5]))&&(playery[1]>platformT[4])))?1:0;
	collisionxU[0]=((((playerx[0]-2)<=platformU[1]))&&((playery[0]<(platformU[5]))&&(playery[1]>platformU[4])))?1:0;
	collisionxV[0]=((((playerx[0]-2)<=platformV[1]))&&((playery[0]<(platformV[5]))&&(playery[1]>platformV[4])))?1:0;
	collisionxW[0]=((((playerx[0]-2)<=platformW[1]))&&((playery[0]<(platformW[5]))&&(playery[1]>platformW[4])))?1:0;
	collisionxX[0]=((((playerx[0]-2)<=platformX[1]))&&((playery[0]<(platformX[5]))&&(playery[1]>platformX[4])))?1:0;
	collisionxY[0]=((((playerx[0]-2)<=platformY[1]))&&((playery[0]<(platformY[5]))&&(playery[1]>platformY[4])))?1:0;
	collisionxZ[0]=((((playerx[0]-2)<=platformZ[1]))&&((playery[0]<(platformZ[5]))&&(playery[1]>platformZ[4])))?1:0;
	collisionxAA[0]=((((playerx[0]-2)<=platformAA[1]))&&((playery[0]<(platformAA[5]))&&(playery[1]>platformAA[4])))?1:0;
	collisionxBB[0]=((((playerx[0]-2)<=platformBB[1]))&&((playery[0]<(platformBB[5]))&&(playery[1]>platformBB[4])))?1:0;
	collisionxCC[0]=((((playerx[0]-2)<=platformCC[1]))&&((playery[0]<(platformCC[5]))&&(playery[1]>platformCC[4])))?1:0;
	collisionxDD[0]=((((playerx[0]-2)<=platformDD[1]))&&((playery[0]<(platformDD[5]))&&(playery[1]>platformDD[4])))?1:0;
	collisionxEE[0]=((((playerx[0]-2)<=platformEE[1]))&&((playery[0]<(platformEE[5]))&&(playery[1]>platformEE[4])))?1:0;
	collisionxFF[0]=((((playerx[0]-2)<=platformFF[1]))&&((playery[0]<(platformFF[5]))&&(playery[1]>platformFF[4])))?1:0;
	
	//right
	collisionxA[1]=((((playerx[1]+2)>=platformA[2]))&&((playery[0]<(platformA[5]))&&(playery[1]>platformA[4])))?1:0;	
	collisionxB[1]=((((playerx[1]+2)>=platformB[2]))&&((playery[0]<(platformB[5]))&&(playery[1]>platformB[4])))?1:0;		
	collisionxC[1]=((((playerx[1]+2)>=platformC[2]))&&((playery[0]<(platformC[5]))&&(playery[1]>platformC[4])))?1:0;				
	collisionxD[1]=((((playerx[1]+2)>=platformD[2]))&&((playery[0]<(platformD[5]))&&(playery[1]>platformD[4])))?1:0;			
	collisionxE[1]=((((playerx[1]+2)>=platformE[2]))&&((playery[0]<(platformE[5]))&&(playery[1]>platformE[4])))?1:0;			
	collisionxF[1]=((((playerx[1]+2)>=platformF[2]))&&((playery[0]<(platformF[5]))&&(playery[1]>platformF[4])))?1:0;			
	collisionxG[1]=((((playerx[1]+2)>=platformG[2]))&&((playery[0]<(platformG[5]))&&(playery[1]>platformG[4])))?1:0;			
	collisionxH[1]=((((playerx[1]+2)>=platformH[2]))&&((playery[0]<(platformH[5]))&&(playery[1]>platformH[4])))?1:0;			
	collisionxI[1]=((((playerx[1]+2)>=platformI[2]))&&((playery[0]<(platformI[5]))&&(playery[1]>platformI[4])))?1:0;			
	collisionxJ[1]=((((playerx[1]+2)>=platformJ[2]))&&((playery[0]<(platformJ[5]))&&(playery[1]>platformJ[4])))?1:0;			
	collisionxK[1]=((((playerx[1]+2)>=platformK[2]))&&((playery[0]<(platformK[5]))&&(playery[1]>platformK[4])))?1:0;			
	collisionxL[1]=((((playerx[1]+2)>=platformL[2]))&&((playery[0]<(platformL[5]))&&(playery[1]>platformL[4])))?1:0;			
	collisionxM[1]=((((playerx[1]+2)>=platformM[2]))&&((playery[0]<(platformM[5]))&&(playery[1]>platformM[4])))?1:0;			
	collisionxN[1]=((((playerx[1]+2)>=platformN[2]))&&((playery[0]<(platformN[5]))&&(playery[1]>platformN[4])))?1:0;			
	collisionxO[1]=((((playerx[1]+2)>=platformO[2]))&&((playery[0]<(platformO[5]))&&(playery[1]>platformO[4])))?1:0;			
	collisionxP[1]=((((playerx[1]+2)>=platformP[2]))&&((playery[0]<(platformP[5]))&&(playery[1]>platformP[4])))?1:0;			
	collisionxQ[1]=((((playerx[1]+2)>=platformQ[2]))&&((playery[0]<(platformQ[5]))&&(playery[1]>platformQ[4])))?1:0;			
	collisionxR[1]=((((playerx[1]+2)>=platformR[2]))&&((playery[0]<(platformR[5]))&&(playery[1]>platformR[4])))?1:0;			
	collisionxS[1]=((((playerx[1]+2)>=platformS[2]))&&((playery[0]<(platformS[5]))&&(playery[1]>platformS[4])))?1:0;			
	collisionxT[1]=((((playerx[1]+2)>=platformT[2]))&&((playery[0]<(platformT[5]))&&(playery[1]>platformT[4])))?1:0;			
	collisionxU[1]=((((playerx[1]+2)>=platformU[2]))&&((playery[0]<(platformU[5]))&&(playery[1]>platformU[4])))?1:0;			
	collisionxV[1]=((((playerx[1]+2)>=platformV[2]))&&((playery[0]<(platformV[5]))&&(playery[1]>platformV[4])))?1:0;			
	collisionxW[1]=((((playerx[1]+2)>=platformW[2]))&&((playery[0]<(platformW[5]))&&(playery[1]>platformW[4])))?1:0;			
	collisionxX[1]=((((playerx[1]+2)>=platformX[2]))&&((playery[0]<(platformX[5]))&&(playery[1]>platformX[4])))?1:0;			
	collisionxY[1]=((((playerx[1]+2)>=platformY[2]))&&((playery[0]<(platformY[5]))&&(playery[1]>platformY[4])))?1:0;			
	collisionxZ[1]=((((playerx[1]+2)>=platformZ[2]))&&((playery[0]<(platformZ[5]))&&(playery[1]>platformZ[4])))?1:0;			
	collisionxAA[1]=((((playerx[1]+2)>=platformAA[2]))&&((playery[0]<(platformAA[5]))&&(playery[1]>platformAA[4])))?1:0;			
	collisionxBB[1]=((((playerx[1]+2)>=platformBB[2]))&&((playery[0]<(platformBB[5]))&&(playery[1]>platformBB[4])))?1:0;			
	collisionxCC[1]=((((playerx[1]+2)>=platformCC[2]))&&((playery[0]<(platformCC[5]))&&(playery[1]>platformCC[4])))?1:0;			
	collisionxDD[1]=((((playerx[1]+2)>=platformDD[2]))&&((playery[0]<(platformDD[5]))&&(playery[1]>platformDD[4])))?1:0;			
	collisionxEE[1]=((((playerx[1]+2)>=platformEE[2]))&&((playery[0]<(platformEE[5]))&&(playery[1]>platformEE[4])))?1:0;			
	collisionxFF[1]=((((playerx[1]+2)>=platformFF[2]))&&((playery[0]<(platformFF[5]))&&(playery[1]>platformFF[4])))?1:0;			
end

always @(posedge CLOCK_50 or negedge key3)
begin
	if(key3==1'b0)
	begin
		//initiate game over
		gameOver<=1'b0;

		//initiate platform type A start
		platformA[0]<=0; //left border
		platformA[1]<=(deck0<=540)?((deck0<=200)?(deck0+150):((deck0>=450)?(deck0-150):deck0)):((deck0-530<=200)?(deck0-530+150):((deck0-530>=450)?(deck0-530-150):(deck0-530))); //begin gap
		platformA[2]<=(deck0<=540)?((deck0<=200)?(deck0+150+90):((deck0>=450)?(deck0-150+90):(deck0+90))):((deck0-530<=200)?(deck0-530+150+90):((deck0-530>=450)?(deck0-530-150+90):(deck0-530+90))); //end gap
		platformA[3]<=640; //right border
		platformA[4]<=128; //top
		platformA[5]<=138; //bottom
		//initiate platform type A end
		platformB[0]<=0; //left border
		platformB[1]<=(deck1<=540)? deck1:(deck1-530); //begin gap
		platformB[2]<=(deck1<=540)?(deck1+90):(deck1+90-530); //end gap
		platformB[3]<=640; //right border
		platformB[4]<=256; //top
		platformB[5]<=266; //bottom
		platformC[0]<=0; //left border
		platformC[1]<=(deck2<=540)? deck2:(deck2-530); //begin gap
		platformC[2]<=(deck2<=540)?(deck2+90):(deck2+90-530); //end gap
		platformC[3]<=640; //right border
		platformC[4]<=384; //top
		platformC[5]<=394; //bottom
		platformD[0]<=0; //left border
		platformD[1]<=(deck3<=540)? deck3:(deck3-530); //begin gap
		platformD[2]<=(deck3<=540)?(deck3+90):(deck3+90-530); //end gap
		platformD[3]<=640; //right border
		platformD[4]<=512; //top
		platformD[5]<=522; //bottom
		platformE[0]<=0; //left border
		platformE[1]<=(deck4<=540)? deck4:(deck4-530); //begin gap
		platformE[2]<=(deck4<=540)?(deck4+90):(deck4+90-530); //end gap
		platformE[3]<=640; //right border
		platformE[4]<=640; //top
		platformE[5]<=650; //bottom
		platformF[0]<=0; //left border
		platformF[1]<=(deck5<=540)? deck5:(deck5-530); //begin gap
		platformF[2]<=(deck5<=540)?(deck5+90):(deck5+90-530); //end gap
		platformF[3]<=640; //right border
		platformF[4]<=768; //top
		platformF[5]<=778; //bottom
		platformG[0]<=0; //left border
		platformG[1]<=(deck6<=540)? deck6:(deck6-530); //begin gap
		platformG[2]<=(deck6<=540)?(deck6+90):(deck6+90-530); //end gap
		platformG[3]<=640; //right border
		platformG[4]<=896; //top
		platformG[5]<=906; //bottom
		platformH[0]<=0; //left border
		platformH[1]<=(deck7<=540)? deck7:(deck7-530); //begin gap
		platformH[2]<=(deck7<=540)?(deck7+90):(deck7+90-530); //end gap
		platformH[3]<=640; //right border
		platformH[4]<=1024; //top
		platformH[5]<=1034; //bottom
		platformI[0]<=0; //left border
		platformI[1]<=(deck8<=540)? deck8:(deck8-530); //begin gap
		platformI[2]<=(deck8<=540)?(deck8+90):(deck8+90-530); //end gap
		platformI[3]<=640; //right border
		platformI[4]<=1152; //top
		platformI[5]<=1162; //bottom
		platformJ[0]<=0; //left border
		platformJ[1]<=(deck9<=540)? deck9:(deck9-530); //begin gap
		platformJ[2]<=(deck9<=540)?(deck9+90):(deck9+90-530); //end gap
		platformJ[3]<=640; //right border
		platformJ[4]<=1280; //top
		platformJ[5]<=1290; //bottom
		platformK[0]<=0; //left border
		platformK[1]<=(deck10<=540)? deck10:(deck10-530); //begin gap
		platformK[2]<=(deck10<=540)?(deck10+90):(deck10+90-530); //end gap
		platformK[3]<=640; //right border
		platformK[4]<=1408; //top
		platformK[5]<=1418; //bottom
		platformL[0]<=0; //left border
		platformL[1]<=(deck11<=540)? deck11:(deck11-530); //begin gap
		platformL[2]<=(deck11<=540)?(deck11+90):(deck11+90-530); //end gap
		platformL[3]<=640; //right border
		platformL[4]<=1536; //top
		platformL[5]<=1546; //bottom
		platformM[0]<=0; //left border
		platformM[1]<=(deck12<=540)? deck12:(deck12-530); //begin gap
		platformM[2]<=(deck12<=540)?(deck12+90):(deck12+90-530); //end gap
		platformM[3]<=640; //right border
		platformM[4]<=1664; //top
		platformM[5]<=1674; //bottom
		platformN[0]<=0; //left border
		platformN[1]<=(deck13<=540)? deck13:(deck13-530); //begin gap
		platformN[2]<=(deck13<=540)?(deck13+90):(deck13+90-530); //end gap
		platformN[3]<=640; //right border
		platformN[4]<=1792; //top
		platformN[5]<=1802; //bottom
		platformO[0]<=0; //left border
		platformO[1]<=(deck14<=540)? deck14:(deck14-530); //begin gap
		platformO[2]<=(deck14<=540)?(deck14+90):(deck14+90-530); //end gap
		platformO[3]<=640; //right border
		platformO[4]<=1920; //top
		platformO[5]<=1930; //bottom
		platformP[0]<=0; //left border
		platformP[1]<=(deck15<=540)? deck15:(deck15-530); //begin gap
		platformP[2]<=(deck15<=540)?(deck15+90):(deck15+90-530); //end gap
		platformP[3]<=640; //right border
		platformP[4]<=2048; //top
		platformP[5]<=2058; //bottom
		platformQ[0]<=0; //left border
		platformQ[1]<=(deck16<=540)? deck16:(deck16-530); //begin gap
		platformQ[2]<=(deck16<=540)?(deck16+90):(deck16+90-530); //end gap
		platformQ[3]<=640; //right border
		platformQ[4]<=2176; //top
		platformQ[5]<=2186; //bottom
		platformR[0]<=0; //left border
		platformR[1]<=(deck17<=540)? deck17:(deck17-530); //begin gap
		platformR[2]<=(deck17<=540)?(deck17+90):(deck17+90-530); //end gap
		platformR[3]<=640; //right border
		platformR[4]<=2304; //top
		platformR[5]<=2314; //bottom
		platformS[0]<=0; //left border
		platformS[1]<=(deck18<=540)? deck18:(deck18-530); //begin gap
		platformS[2]<=(deck18<=540)?(deck18+90):(deck18+90-530); //end gap
		platformS[3]<=640; //right border
		platformS[4]<=2432; //top
		platformS[5]<=2442; //bottom
		platformT[0]<=0; //left border
		platformT[1]<=(deck19<=540)? deck19:(deck19-530); //begin gap
		platformT[2]<=(deck19<=540)?(deck19+90):(deck19+90-530); //end gap
		platformT[3]<=640; //right border
		platformT[4]<=2560; //top
		platformT[5]<=2570; //bottom
		platformU[0]<=0; //left border
		platformU[1]<=(deck20<=540)? deck20:(deck20-530); //begin gap
		platformU[2]<=(deck20<=540)?(deck20+90):(deck20+90-530); //end gap
		platformU[3]<=640; //right border
		platformU[4]<=2688; //top
		platformU[5]<=2698; //bottom
		platformV[0]<=0; //left border
		platformV[1]<=(deck21<=540)? deck21:(deck21-530); //begin gap
		platformV[2]<=(deck21<=540)?(deck21+90):(deck21+90-530); //end gap
		platformV[3]<=640; //right border
		platformV[4]<=2816; //top
		platformV[5]<=2826; //bottom
		platformW[0]<=0; //left border
		platformW[1]<=(deck22<=540)? deck22:(deck22-530); //begin gap
		platformW[2]<=(deck22<=540)?(deck22+90):(deck22+90-530); //end gap
		platformW[3]<=640; //right border
		platformW[4]<=2944; //top
		platformW[5]<=2954; //bottom
		platformX[0]<=0; //left border
		platformX[1]<=(deck23<=540)? deck23:(deck23-530); //begin gap
		platformX[2]<=(deck23<=540)?(deck23+90):(deck23+90-530); //end gap
		platformX[3]<=640; //right border
		platformX[4]<=3072; //top
		platformX[5]<=3082; //bottom
		platformY[0]<=0; //left border
		platformY[1]<=(deck24<=540)? deck24:(deck24-530); //begin gap
		platformY[2]<=(deck24<=540)?(deck24+90):(deck24+90-530); //end gap
		platformY[3]<=640; //right border
		platformY[4]<=3200; //top
		platformY[5]<=3210; //bottom
		platformZ[0]<=0; //left border
		platformZ[1]<=(deck25<=540)? deck25:(deck25-530); //begin gap
		platformZ[2]<=(deck25<=540)?(deck25+90):(deck25+90-530); //end gap
		platformZ[3]<=640; //right border
		platformZ[4]<=3328; //top
		platformZ[5]<=3338; //bottom
		platformAA[0]<=0; //left border
		platformAA[1]<=(deck26<=540)? deck26:(deck26-530); //begin gap
		platformAA[2]<=(deck26<=540)?(deck26+90):(deck26+90-530); //end gap
		platformAA[3]<=640; //right border
		platformAA[4]<=3456; //top
		platformAA[5]<=3466; //bottom
		platformBB[0]<=0; //left border
		platformBB[1]<=(deck27<=540)? deck27:(deck27-530); //begin gap
		platformBB[2]<=(deck27<=540)?(deck27+90):(deck27+90-530); //end gap
		platformBB[3]<=640; //right border
		platformBB[4]<=3584; //top
		platformBB[5]<=3594; //bottom
		platformCC[0]<=0; //left border
		platformCC[1]<=(deck28<=540)? deck28:(deck28-530); //begin gap
		platformCC[2]<=(deck28<=540)?(deck28+90):(deck28+90-530); //end gap
		platformCC[3]<=640; //right border
		platformCC[4]<=3712; //top
		platformCC[5]<=3722; //bottom
		platformDD[0]<=0; //left border
		platformDD[1]<=(deck29<=540)? deck29:(deck29-530); //begin gap
		platformDD[2]<=(deck29<=540)?(deck29+90):(deck29+90-530); //end gap
		platformDD[3]<=640; //right border
		platformDD[4]<=3840; //top
		platformDD[5]<=3850; //bottom
		platformEE[0]<=0; //left border
		platformEE[1]<=(deck30<=540)? deck30:(deck30-530); //begin gap
		platformEE[2]<=(deck30<=540)?(deck30+90):(deck30+90-530); //end gap
		platformEE[3]<=640; //right border
		platformEE[4]<=3968; //top
		platformEE[5]<=3978; //bottom
		platformFF[0]<=0; //left border
		platformFF[1]<=(deck31<=540)? deck31:(deck31-530); //begin gap
		platformFF[2]<=(deck31<=540)?(deck31+90):(deck31+90-530); //end gap
		platformFF[3]<=640; //right border
		platformFF[4]<=4085; //top
		platformFF[5]<=4095; //bottom
		
		//initiate player start
		playerx[0]<=280; //left
		playerx[1]<=310; //right
		playery[0]<=90; //top
		playery[1]<=120; //bot
		
	end
	
	//start update vga
	else if (count>=TIMER)
	begin 
			count<=0;
	//player movement
	begin
		//game over check
		if(collisiony[0] == 1)
			begin
			gameOver <= 1'b1;
			end
	
		//left movement
		if(key1 == 0 && collisionx[1]==0 && collisionxA[1]==0 && collisionxB[1]==0 && collisionxC[1]==0 && collisionxD[1]==0 && collisionxE[1]==0
		 && collisionxF[1]==0 && collisionxG[1]==0 && collisionxH[1]==0 && collisionxI[1]==0 && collisionxJ[1]==0 && collisionxK[1]==0 && collisionxL[1]==0
		 && collisionxM[1]==0 && collisionxN[1]==0 && collisionxO[1]==0 && collisionxP[1]==0 && collisionxQ[1]==0 && collisionxR[1]==0 && collisionxS[1]==0
		 && collisionxT[1]==0 && collisionxU[1]==0 && collisionxV[1]==0 && collisionxW[1]==0 && collisionxX[1]==0 && collisionxY[1]==0 && collisionxZ[1]==0
		 && collisionxAA[1]==0 && collisionxBB[1]==0 && collisionxCC[1]==0 && collisionxDD[1]==0 && collisionxEE[1]==0 && collisionxFF[1]==0) //right
			begin
			playerx[0]<=playerx[0]+4;
			playerx[1]<=playerx[1]+4;
			end
		
		//right movement
	   else if(key2 == 0 && collisionx[0]==0 && collisionxA[0]==0 && collisionxB[0]==0 && collisionxC[0]==0 && collisionxD[0]==0 && collisionxE[0]==0
		 && collisionxF[0]==0 && collisionxG[0]==0 && collisionxH[0]==0 && collisionxI[0]==0 && collisionxJ[0]==0 && collisionxK[0]==0 && collisionxL[0]==0
		 && collisionxM[0]==0 && collisionxN[0]==0 && collisionxO[0]==0 && collisionxP[0]==0 && collisionxQ[0]==0 && collisionxR[0]==0 && collisionxS[0]==0
		 && collisionxT[0]==0 && collisionxU[0]==0 && collisionxV[0]==0 && collisionxW[0]==0 && collisionxX[0]==0 && collisionxY[0]==0 && collisionxZ[0]==0
		 && collisionxAA[0]==0 && collisionxBB[0]==0 && collisionxCC[0]==0 && collisionxDD[0]==0 && collisionxEE[0]==0 && collisionxFF[0]==0) //left
			begin
			playerx[0]<=playerx[0]-4;
			playerx[1]<=playerx[1]-4;
			end
		
		//falling movement
		if(collisionyA[0]==0 && collisiony[1] == 0 && collisionyB[0]==0 && collisionyC[0]==0 && collisionyD[0]==0 && collisionyE[0]==0 && collisionyF[0]==0
		&& collisionyG[0]==0 && collisionyH[0]==0 && collisionyI[0]==0 && collisionyJ[0]==0 && collisionyK[0]==0 && collisionyL[0]==0 && collisionyM[0]==0
		&& collisionyN[0]==0 && collisionyO[0]==0 && collisionyP[0]==0 && collisionyQ[0]==0 && collisionyR[0]==0 && collisionyS[0]==0 && collisionyT[0]==0
		&& collisionyU[0]==0 && collisionyV[0]==0 && collisionyW[0]==0 && collisionyX[0]==0 && collisionyY[0]==0 && collisionyZ[0]==0 && collisionyAA[0]==0
		&& collisionyBB[0]==0 && collisionyCC[0]==0 && collisionyDD[0]==0 && collisionyEE[0]==0 && collisionyFF[0]==0)
			begin
			playery[0]<=playery[0]+1;
			playery[1]<=playery[1]+1;
			end
		
		//upward movement		
		if (collisionyA[0]==1)
			begin
			playery[1]<=platformA[4]-2;
			playery[0]<=playery[1] - 30;
			end	
		if (collisionyB[0]==1)
			begin
			playery[1]<=platformB[4]-2;
			playery[0]<=playery[1] - 30;
			end
		if (collisionyC[0]==1)
			begin
			playery[1]<=platformC[4]-2;
			playery[0]<=playery[1] - 30;
			end
		if (collisionyD[0]==1)
			begin
			playery[1]<=platformD[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyE[0]==1)
			begin
			playery[1]<=platformE[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyF[0]==1)
			begin
			playery[1]<=platformF[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyG[0]==1)
			begin
			playery[1]<=platformG[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyH[0]==1)
			begin
			playery[1]<=platformH[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyI[0]==1)
			begin
			playery[1]<=platformI[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyJ[0]==1)
			begin
			playery[1]<=platformJ[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyK[0]==1)
			begin
			playery[1]<=platformK[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyL[0]==1)
			begin
			playery[1]<=platformL[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyM[0]==1)
			begin
			playery[1]<=platformM[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyN[0]==1)
			begin
			playery[1]<=platformN[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyO[0]==1)
			begin
			playery[1]<=platformO[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyP[0]==1)
			begin
			playery[1]<=platformP[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyQ[0]==1)
			begin
			playery[1]<=platformQ[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyR[0]==1)
			begin
			playery[1]<=platformR[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyS[0]==1)
			begin
			playery[1]<=platformS[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyT[0]==1)
			begin
			playery[1]<=platformT[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyU[0]==1)
			begin
			playery[1]<=platformU[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyV[0]==1)
			begin
			playery[1]<=platformV[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyW[0]==1)
			begin
			playery[1]<=platformW[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyV[0]==1)
			begin
			playery[1]<=platformV[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyX[0]==1)
			begin
			playery[1]<=platformX[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyY[0]==1)
			begin
			playery[1]<=platformY[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyZ[0]==1)
			begin
			playery[1]<=platformZ[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyAA[0]==1)
			begin
			playery[1]<=platformAA[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyBB[0]==1)
			begin
			playery[1]<=platformBB[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyCC[0]==1)
			begin
			playery[1]<=platformCC[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyDD[0]==1)
			begin
			playery[1]<=platformDD[4]-2;
			playery[0]<=playery[1] - 30;
			end			
		if (collisionyEE[0]==1)
			begin
			playery[1]<=platformEE[4]-2;
			playery[0]<=playery[1] - 30;
			end
		if (collisionyFF[0]==1)
			begin
			playery[1]<=platformFF[4]-2;
			playery[0]<=playery[1] - 30;
			end
	end
 
	//platform movement
	platformA[4] <= platformA[4]-2;
	platformA[5] <= platformA[5]-2;
	platformB[4] <= platformB[4]-2;
	platformB[5] <= platformB[5]-2;
	platformC[4] <= platformC[4]-2;
	platformC[5] <= platformC[5]-2;
	platformD[4] <= platformD[4]-2;
	platformD[5] <= platformD[5]-2;
	platformE[4] <= platformE[4]-2;
	platformE[5] <= platformE[5]-2;
	platformF[4] <= platformF[4]-2;
	platformF[5] <= platformF[5]-2;
	platformG[4] <= platformG[4]-2;
	platformG[5] <= platformG[5]-2;
	platformH[4] <= platformH[4]-2;
	platformH[5] <= platformH[5]-2;
	platformI[4] <= platformI[4]-2;
	platformI[5] <= platformI[5]-2;
	platformJ[4] <= platformJ[4]-2;
	platformJ[5] <= platformJ[5]-2;
	platformK[4] <= platformK[4]-2;
	platformK[5] <= platformK[5]-2;
	platformL[4] <= platformL[4]-2;
	platformL[5] <= platformL[5]-2;
	platformM[4] <= platformM[4]-2;
	platformM[5] <= platformM[5]-2;
	platformN[4] <= platformN[4]-2;
	platformN[5] <= platformN[5]-2;
	platformO[4] <= platformO[4]-2;
	platformO[5] <= platformO[5]-2;
	platformP[4] <= platformP[4]-2;
	platformP[5] <= platformP[5]-2;
	platformQ[4] <= platformQ[4]-2;
	platformQ[5] <= platformQ[5]-2;
	platformR[4] <= platformR[4]-2;
	platformR[5] <= platformR[5]-2;
	platformS[4] <= platformS[4]-2;
	platformS[5] <= platformS[5]-2;
	platformT[4] <= platformT[4]-2;
	platformT[5] <= platformT[5]-2;
	platformU[4] <= platformU[4]-2;
	platformU[5] <= platformU[5]-2;
	platformV[4] <= platformV[4]-2;
	platformV[5] <= platformV[5]-2;
	platformW[4] <= platformW[4]-2;
	platformW[5] <= platformW[5]-2;
	platformX[4] <= platformX[4]-2;
	platformX[5] <= platformX[5]-2;
	platformY[4] <= platformY[4]-2;
	platformY[5] <= platformY[5]-2;
	platformZ[4] <= platformZ[4]-2;
	platformZ[5] <= platformZ[5]-2;
	platformAA[4] <= platformAA[4]-2;
	platformAA[5] <= platformAA[5]-2;
	platformBB[4] <= platformBB[4]-2;
	platformBB[5] <= platformBB[5]-2;
	platformCC[4] <= platformCC[4]-2;
	platformCC[5] <= platformCC[5]-2;
	platformDD[4] <= platformDD[4]-2;
	platformDD[5] <= platformDD[5]-2;
	platformEE[4] <= platformEE[4]-2;
	platformEE[5] <= platformEE[5]-2;
	platformFF[4] <= platformFF[4]-2;
	platformFF[5] <= platformFF[5]-2;
	end//end of updtae vga

	//timer incriment
	else
	begin
		count<=count+50;
	end
end

//begin colouring
always
	//you lose screen
	if(gameOver == 1'b1)
		begin
		if ((py>=215 && py<=225) &&((px>=135 && px<=145)||(px>=175 && px<=185)||(px>=200 && px<=230)||(px>=245 && px<=255)||(px>=285 && px<=295)||(px>=300 && px<=310)||(px>=365 && px<=395)||(px>=420 && px<=460)||(px>=465 && px<=515)))//1
		begin
		valid <=1'b1;
		red<=1'b1;
		blue<=1'b0;
		green<=1'b0;
		end
		else if ((py>=225 && py<=235) &&((px>=145 && px<=155)||(px>=165 && px<=175)||(px>=190 && px<=200)||(px>=230 && px<=240)||(px>=245 && px<=255)||(px>=285 && px<=295)||(px>=300 && px<=310)||(px>=355 && px<=365)||(px>=395 && px<=405)||(px>=410 && px<=420)||(px>=465 && px<=475)))//2
		begin
		valid <=1'b1;
		red<=1'b1;
		blue<=1'b0;
		green<=1'b0;
		end
		else if ((py>=235 && py<=245) &&((px>=155 && px<=165)||(px>=190 && px<=200)||(px>=230 && px<=240)||(px>=245 && px<=255)||(px>=285 && px<=295)||(px>=300 && px<=310)||(px>=355 && px<=365)||(px>=395 && px<=405)||(px>=420 && px<=450)||(px>=465 && px<=515)))//3
		begin
		valid <=1'b1;
		red<=1'b1;
		blue<=1'b0;
		green<=1'b0;
		end
		else if ((py>=245 && py<=255) &&((px>=155 && px<=165)||(px>=190 && px<=200)||(px>=230 && px<=240)||(px>=245 && px<=255)||(px>=285 && px<=295)||(px>=300 && px<=310)||(px>=355 && px<=365)||(px>=395 && px<=405)||(px>=450 && px<=460)||(px>=465 && px<=475)))//4
		begin
		valid <=1'b1;
		red<=1'b1;
		blue<=1'b0;
		green<=1'b0;
		end
		else if ((py>=255 && py<=265) &&((px>=155 && px<=165)||(px>=200 && px<=230)||(px>=255 && px<=285)||(px>=300 && px<=350)||(px>=365 && px<=395)||(px>=410 && px<=450)||(px>=465 && px<=515)))//5
		begin
		valid <=1'b1;
		red<=1'b1;
		blue<=1'b0;
		green<=1'b0;
		end 
		else
		begin
		valid <=1'b1;
		red<=1'b0;
		blue<=1'b0;
		green<=1'b0;
		end	
	end
	//color platforms
	else if ((py>=platformA[4] && py<=platformA[5])&&((px>=platformA[0] && px<=platformA[1])||(px>=platformA[2] && px<=platformA[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end
	else if ((py>=platformB[4] && py<=platformB[5])&&((px>=platformB[0] && px<=platformB[1])||(px>=platformB[2] && px<=platformB[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end	
	else if ((py>=platformC[4] && py<=platformC[5])&&((px>=platformC[0] && px<=platformC[1])||(px>=platformC[2] && px<=platformC[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end	
	else if ((py>=platformD[4] && py<=platformD[5])&&((px>=platformD[0] && px<=platformD[1])||(px>=platformD[2] && px<=platformD[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end	
	else if ((py>=platformE[4] && py<=platformE[5])&&((px>=platformE[0] && px<=platformE[1])||(px>=platformE[2] && px<=platformE[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformF[4] && py<=platformF[5])&&((px>=platformF[0] && px<=platformF[1])||(px>=platformF[2] && px<=platformF[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformG[4] && py<=platformG[5])&&((px>=platformG[0] && px<=platformG[1])||(px>=platformG[2] && px<=platformG[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformH[4] && py<=platformH[5])&&((px>=platformH[0] && px<=platformH[1])||(px>=platformH[2] && px<=platformH[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformI[4] && py<=platformI[5])&&((px>=platformI[0] && px<=platformI[1])||(px>=platformI[2] && px<=platformI[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformJ[4] && py<=platformJ[5])&&((px>=platformJ[0] && px<=platformJ[1])||(px>=platformJ[2] && px<=platformJ[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformK[4] && py<=platformK[5])&&((px>=platformK[0] && px<=platformK[1])||(px>=platformK[2] && px<=platformK[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformL[4] && py<=platformL[5])&&((px>=platformL[0] && px<=platformL[1])||(px>=platformL[2] && px<=platformL[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformM[4] && py<=platformM[5])&&((px>=platformM[0] && px<=platformM[1])||(px>=platformM[2] && px<=platformM[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformN[4] && py<=platformN[5])&&((px>=platformN[0] && px<=platformN[1])||(px>=platformN[2] && px<=platformN[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformO[4] && py<=platformO[5])&&((px>=platformO[0] && px<=platformO[1])||(px>=platformO[2] && px<=platformO[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformP[4] && py<=platformP[5])&&((px>=platformP[0] && px<=platformP[1])||(px>=platformP[2] && px<=platformP[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformQ[4] && py<=platformQ[5])&&((px>=platformQ[0] && px<=platformQ[1])||(px>=platformQ[2] && px<=platformQ[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformR[4] && py<=platformR[5])&&((px>=platformR[0] && px<=platformR[1])||(px>=platformR[2] && px<=platformR[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformS[4] && py<=platformS[5])&&((px>=platformS[0] && px<=platformS[1])||(px>=platformS[2] && px<=platformS[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformT[4] && py<=platformT[5])&&((px>=platformT[0] && px<=platformT[1])||(px>=platformT[2] && px<=platformT[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformU[4] && py<=platformU[5])&&((px>=platformU[0] && px<=platformU[1])||(px>=platformU[2] && px<=platformU[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformV[4] && py<=platformV[5])&&((px>=platformV[0] && px<=platformV[1])||(px>=platformV[2] && px<=platformV[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformW[4] && py<=platformW[5])&&((px>=platformW[0] && px<=platformW[1])||(px>=platformW[2] && px<=platformW[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformX[4] && py<=platformX[5])&&((px>=platformX[0] && px<=platformX[1])||(px>=platformX[2] && px<=platformX[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformY[4] && py<=platformY[5])&&((px>=platformY[0] && px<=platformY[1])||(px>=platformY[2] && px<=platformY[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformZ[4] && py<=platformZ[5])&&((px>=platformZ[0] && px<=platformZ[1])||(px>=platformZ[2] && px<=platformZ[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformAA[4] && py<=platformAA[5])&&((px>=platformAA[0] && px<=platformAA[1])||(px>=platformAA[2] && px<=platformAA[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformBB[4] && py<=platformBB[5])&&((px>=platformBB[0] && px<=platformBB[1])||(px>=platformBB[2] && px<=platformBB[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformCC[4] && py<=platformCC[5])&&((px>=platformCC[0] && px<=platformCC[1])||(px>=platformCC[2] && px<=platformCC[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformDD[4] && py<=platformDD[5])&&((px>=platformDD[0] && px<=platformDD[1])||(px>=platformDD[2] && px<=platformDD[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end		
	else if ((py>=platformEE[4] && py<=platformEE[5])&&((px>=platformEE[0] && px<=platformEE[1])||(px>=platformEE[2] && px<=platformEE[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end	
	else if ((py>=platformFF[4] && py<=platformFF[5])&&((px>=platformFF[0] && px<=platformFF[1])||(px>=platformFF[2] && px<=platformFF[3])))
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b1;
	green<=1'b0;
	end			
	//color player
	else if (py>=playery[0] && py<=playery[1] && px>=playerx[0] && px<=playerx[1]) 
	begin
	valid <=1'b1;
	red<=1'b1;
	blue<=1'b0;
	green<=1'b0;
	end
	//color background
	else 
	begin
	valid <=1'b1;
	red<=1'b0;
	blue<=1'b0;
	green<=1'b0;
	end

	assign pixel = 1'b1;
endmodule